﻿using System;
using System.Collections.Generic;

using E.BLL;
using E.Model;
using E.Web.UI.Page;

using X.Common;

namespace E.Web.training.interactive
{
    public partial class QandA : BasePage
    {
        public Dictionary<int, string> teacherList;

        protected override void ShowPage()
        {
            if (authority == E.Enum.EnumUserAuthority.Public)
            {
                teacherList = (new TeacherBLL()).GetTeacherByArea(areaid);
            }
            else
            {
                teacherList = (new TeacherBLL()).GetTeacherByProjectID((new UserBLL()).GetUserProjectID(userid));
            }

            if (ispost)
            {
                int teacherID = XRequest.GetInt("TeacherListSlt", -1);
                string content = XRequest.GetString("QuestionTxt");

                if (teacherID != -1 && !content.Equals(""))
                {
                    QandAModel model = new QandAModel();
                    model.UserID = userid;
                    model.ParentID = 0;
                    model.TeacherID = teacherID;
                    model.Content = content;
                    model.AddDate = DateTime.Now;

                    int rst = (new TeacherBLL()).AddQuestion(model);
                    if (rst > 0)
                    {
                        Alert("提交成功");
                    }
                    else
                    {
                        Alert("提交失败，请稍后再试");
                    }
                }
                else
                {
                    Alert("请正确填写信息");
                }
            }
        }
    }
}
